﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/HomeSite.Master" Inherits="System.Web.Mvc.ViewPage<TimeTableManagement.Entities.Tb_People>" %>

<%@ Register Assembly="DevExpress.Web.v11.1, Version=11.1.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxTabControl" TagPrefix="dx" %>

<%@ Register assembly="DevExpress.Web.v11.1, Version=11.1.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxClasses" tagprefix="dx" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">

<script src="<%: Url.Content("~/Scripts/jquery.validate.min.js") %>" type="text/javascript"></script>
<script src="<%: Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js") %>" type="text/javascript"></script>

<% using (Html.BeginForm()) { %>
    
    <dx:ASPxPageControl ID="ASPxPageControl1" runat="server" ActiveTabIndex="0" 
        CssFilePath="~/App_Themes/Aqua/{0}/styles.css" CssPostfix="Aqua" Width="100%"
        SpriteCssFilePath="~/App_Themes/Aqua/{0}/sprite.css" TabSpacing="3px">
        <TabPages>
            <dx:TabPage Text="Student">
                <ContentCollection>
                    <dx:ContentControl runat="server" SupportsDisabledAttribute="True">
                    
<%--                        noi dung tab 1--%>
                    <div class="editor-label">
                        <%: Html.LabelFor(model => model.mssv, "MSSV")%>
                    </div>
                    <div class="editor-field">
                        <%: Html.EditorFor(model => model.mssv) %>
                        <%: Html.ValidationMessageFor(model => model.mssv) %>
                    </div>

                    <div class="editor-label">
                        <%: Html.LabelFor(model => model.name,"Name") %>
                    </div>
                    <div class="editor-field">
                        <%: Html.EditorFor(model => model.name) %>
                        <%: Html.ValidationMessageFor(model => model.name) %>
                    </div>

                    <div class="editor-label">
                        <%: Html.LabelFor(model => model.id_department, "Department") %>
                    </div>
                    <div class="editor-field">
                        <%: Html.DropDownList("id_department", String.Empty) %>
                        <%: Html.ValidationMessageFor(model => model.id_department) %>
                    </div>
                    <input id="type" name="type" value="13" type="hidden" />
                        
                     </dx:ContentControl>
                </ContentCollection>
            </dx:TabPage>
            <dx:TabPage Text="Profile">
                <ContentCollection>
                    <dx:ContentControl runat="server" SupportsDisabledAttribute="True">
<%--                        noi dung tab 2--%>
                        
                        <% 
                            TimeTableManagement.QLSVContext db = new TimeTableManagement.QLSVContext();
                            var list = db.Tb_Config.Where(g=>g.option.Equals("profile"));
                       foreach (TimeTableManagement.Entities.Tb_Config item in list)
                       { %>
                        <div class="display-label"><%: Html.Label(item.displayword) %></div>
                        <div class="display-field"><%--<%: item.id %> day la id_keywordprofile--%>
                            <input id="<%: item.id %>" name="<%: item.keyword %>" 
                            keyword="<%: item.keyword %>" class="profileitem" type="text"/>
                            
                        </div>
                       <% } %>
                     </dx:ContentControl>
                </ContentCollection>
            </dx:TabPage>
        </TabPages>
        <LoadingPanelImage Url="~/App_Themes/Aqua/Web/Loading.gif">
        </LoadingPanelImage>
        <Paddings Padding="2px" PaddingLeft="5px" PaddingRight="5px" />
        <ContentStyle>
            <Border BorderColor="#AECAF0" BorderStyle="Solid" BorderWidth="1px" />
        </ContentStyle>
    </dx:ASPxPageControl>
        
        <input id="profile" name="profile" type="hidden" />
        <%--Cập nhật JS cho profile--%>
        <p>
            <%: Html.ValidationSummary(true) %>
            <input type="submit" value="Create" onclick="return updatejson()" />
        </p>
<% } %>

<div>
    <%: Html.ActionLink("Back to List", "Index") %>
</div>

</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="HeadContent" runat="server">
<script>
    function updatejson() {
        $json = "";
        $items = document.getElementsByClassName('profileitem');
        for ($i = 0; $i < $items.length; $i++) {
            $item = $items.item($i);
            $id = $item.id;
            $keyword = $item.getAttribute('keyword');
            $value = $item.value;
            $value = $value.replace(/^\s+|\s+$/g, "");
            $json = $json + ',{"id":' + $id + ',"key":"' + $keyword + '","value":"' + $value + '"}';
        }
        $json = '[' + $json.substr(1) + ']';
        document.getElementById('profile').value = $json;
        return true;
    }
</script>
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="leftmenu" runat="server">
</asp:Content>

<asp:Content ID="Content4" ContentPlaceHolderID="menuright" runat="server">
</asp:Content>

<asp:Content ID="Content5" ContentPlaceHolderID="Footer" runat="server">
</asp:Content>
